<template>
  <el-upload
    class="upload-demo"
    action="http://localhost:3000/upload/img"
    :on-preview="handlePreview"
    :on-remove="handleRemove"
    :before-remove="beforeRemove"
    :on-success="handleSUccess"
    multiple
    :limit="1"
    :file-list="fileList"
  >
    <el-button size="small" type="primary">点击上传</el-button>
    <div slot="tip" class="el-upload__tip">请上传文件</div>
  </el-upload>
</template>

<script>
export default {
  name: 'Post',
  data() {
    return {
      fileList: [],
    }
  },
  methods: {
    handleSUccess(res, file, fileList) {
      console.log(res)
    },
    handleRemove(file, fileList) {
      console.log(file.response)
      this.$http.post('/upload/del', file.response).then((res) => {})
    },
    handlePreview(file) {
      // console.log(file)
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
  },
}
</script>

<style></style>
